<%--
 *  File:    MDSnapShotSummary.jsp
 *  @Author: TerryCui
 *  Date:    2011.1.24

 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>
<%
	String strModuleName = "IMG";
	String strTableName = "v_mdsnapshotsummary";
	String privilegeCode = "Z0834";
	String contextPath = request.getContextPath();
%>


<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title>MDSnapShotSummary</title>
<PageFlow:CheckPageFlow pageName="p_mdsnapshotsummary"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%=strLanguageCode%>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/SummaryDivision.js"></script>
<%@include file="/inc/SumDiv.inc"%>
<script>
function page_summary(actionvalue,orderbyname){
	  var editform = summaryPrepare(thisform,actionvalue,orderbyname);
	  editform.action = "MDSnapShotSummary.jsp?<%= OvalTools.randomURL() %>";
	  editform.target = "_self";
	  isRunning = true;
	  editform.submit();
}
function page_radiotrue(obj,id,status,successflag){
  radiotrue(obj);
  thisform.mdsnapshotid.value = id;
  thisform.status.value = status;
  thisform.successflag.value = successflag
  
}
function page_info(id){
  if(!isEmpty(id) && id!=-1)
  {
    self.location.href="MDSnapShotMain.jsp?<%= OvalTools.randomURL() %>&displayflag=view&mdsnapshotid="+id;
  }
}
function page_new(){
  self.location.href="MDSnapShotMain.jsp?<%= OvalTools.randomURL() %>";
}
function page_edit(){
  var id=thisform.mdsnapshotid.value;
  if(isEmpty(id) || id =='-1')
  {
    alert("<%= message.getMessageDesc("PLEASE_SELECT") %>");
    return;
  }   
  self.location.href="MDSnapShotMain.jsp?<%= OvalTools.randomURL() %>&mdsnapshotid="+id;
}
function page_delete(){
  var id = thisform.mdsnapshotid.value;
  if(isEmpty(id) || id =='-1')
  {
    alert("<%= message.getMessageDesc("PLEASE_SELECT") %>");
    return;
  }

  if(thisform.status.value == 41)
  {
    alert('<%= message.getMessage("CAN_NOT_DEL_IT")%>');
  	return;
  }
  var flag = confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>");
  if(!flag)
    return;
  thisform.actionname.value = "delete";
  thisform.target = "_self";
  isRunning = true;
  thisform.submit();
}
function page_execute(){
	var successflag = thisform.successflag.value;
	if(successflag != 3){
		alert('<%= message.getMessage("ONLY_FLAG_BE_FALSE_CAN_MANUAL_EXECUTE")%>');
		return;
	}
	thisform.actionname.value = "execute";
	thisform.target = "_self";
	isRunning = true;
	thisform.submit();	
}

var popwindow;
function page_viewLog(mdsnapshotid){
	if(popwindow!=null)
		popwindow.close();
	popwindow = window.open('MDSnapShotLog.jsp?<%= OvalTools.randomURL() %>&mdsnapshotid=' + mdsnapshotid,'newwindow', 'height=400px, width=600px,top=200px,left=200px,toolbar=n0, menubar=no, scrollbars=no, resizable=no, location=no, status=no');
}
</script>
</head>
<body>
<form name="thisform" method="post" action="<%=contextPath%>/Dispatcher"  target="_parent">
    <input type="hidden" name="pagename" value="p_mdsnapshotsummary">
    <input type="hidden" name="actionname">
<%@ include file="/inc/PageLocation.inc" %>
  <table width="100%" cellspacing="0" border="0" cellpadding="0">
    <tr> 
      <td> 
        <table width="100%" border="0" cellspacing="0">
          <%@ include file="/inc/SummarySearch.inc" %>
        </table>
        <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
          <tr class="deepblue-left"> 
            <td width="25px" class="title_center">&nbsp;</td>
            <td width="100px" class="title_center"><a href="javascript:page_summary('orderby','mdsnapshotcode')"><%=label.getLabelName("L_SnapShotCode")%></a></td>
            <td class="title_center"><a href="javascript:page_summary('orderby','mdsnapshotname')"><%=label.getLabelName("L_SnapShotName")%></a></td>
            <td width="100px" class="title_center"><a href="javascript:page_summary('orderby','masterdataname')"><%=label.getLabelName("L_MasterData")%></a></td>
            <td width="300px" class="title_center"><a href="javascript:page_summary('orderby','description')"><%=label.getLabelName("L_Description")%></a></td>
            <td width="50px" class="title_center"><a href="javascript:page_summary('orderby','statusname')"><%=label.getLabelName("L_Status")%></a></td>
            <td width="75px" class="title_center"><%=label.getLabelName("L_RunResult")%></td>
          </tr>
          <%
            Vector mdsnapshots = (Vector)pageContext.getAttribute("mdsnapshots");
            if(mdsnapshots == null)
            	mdsnapshots = new Vector();
            int i = 0;
            boolean bHasChecked = false;
            Integer nDefaultId = new Integer(-1);
            Integer nDefaultStatus = new Integer(-1);
            Integer nDefaultFlag = new Integer(-1);
            Integer mdSnapShotId = new Integer(-1);
          %>
          <logic:iterate id="onemdsnapshot" collection="<%= mdsnapshots %>" indexId="idx"> 
          <%
				HashMap tempMap = (HashMap)pageContext.getAttribute("onemdsnapshot");
          		mdSnapShotId = (Integer)(tempMap.get("mdsnapshotid"));
	            String strIsChecked = "";
	            String strClassType="";
	            if(i%2 == 1){
	              	strClassType = "td-listrom";  
	            }else{
	              	strClassType = "";
	            }
	            if(!bHasChecked){
	            	strIsChecked = "Checked";
	              	bHasChecked = true;
	              	nDefaultId = (Integer)(tempMap.get("mdsnapshotid"));
	              	nDefaultStatus = (Integer)(tempMap.get("status"));
	              	nDefaultFlag = (Integer)(tempMap.get("successflag"));
	            }
	            i++;
	        %>
          <tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull(strClassType)%>'"  onClick="javascript:page_radiotrue('mdsnapshotids<%=JspHelper.filterNull(idx)%>','<custom:write name="onemdsnapshot" property="mdsnapshotid"/>','<custom:write name="onemdsnapshot" property="status"/>','<custom:write name="onemdsnapshot" property="successflag"/>');" class="<%=JspHelper.filterNull(strClassType)%>"> 
            <td> 
              <input id="mdsnapshotids<%=JspHelper.filterNull(idx)%>" type="radio" name="mdsnapshotids" value="<custom:write name="onemdsnapshot" property="mdsnapshotid"/>" class="normalradio" <%=JspHelper.filterNull(strIsChecked)%>>
            </td>
            <td><a href="javascript:page_info('<custom:write name="onemdsnapshot" property="mdsnapshotid"/>');"><custom:write name="onemdsnapshot" property="mdsnapshotcode" nbsp="true"/></a></td>
            <td><custom:write name="onemdsnapshot" property="mdsnapshotname" nbsp="true"/></td>
            <td><custom:write name="onemdsnapshot" property="masterdataname" nbsp="true"/></td>
            <td><custom:write name="onemdsnapshot" property="description" dataType="date" dataFormatName="dateformat" nbsp="true"/></td>
            <td><custom:write name="onemdsnapshot" property="statusname" nbsp="true"/></td>
            <td>
            	<a onclick="page_viewLog(<%=mdSnapShotId%>)"><custom:write name="onemdsnapshot" property="successflag" dictType="SuccessFlag" nbsp="true"/></a>
            </td>
          </tr>
          </logic:iterate>
          <%@ include file="/inc/SummaryAction.inc" %>
        </table>
        <table width="100%" cellspacing="0" cellpadding="0">
          <tr>
          	<td class="summary_top" ></td>
          </tr>
          <tr>
            <td class="td_center"> 
              <input type="hidden" name="mdsnapshotid" value="<%=JspHelper.filterNull(nDefaultId)%>"/>
              <input type="hidden" name="status" value="<%=JspHelper.filterNull(nDefaultStatus)%>"/>
              <input type="hidden" name="successflag" value="<%=JspHelper.filterNull(nDefaultFlag)%>"/>
              <a onclick="page_new();"><custom:button type="1" label="L_New" border="0" style="width:60"/></a>
              <%if(mdsnapshots.size()>0){%>
	              <a onclick="page_edit();"><custom:button type="1" label="L_Edit" border="0" style="width:60"/></a>
	              <a onclick="page_delete();"><custom:button type="1" label="L_Delete" border="0" style="width:60"/></a>
	              <a onclick="page_execute();"><custom:button type="1" label="L_ManualExecute" border="0" style="width:60"/></a>
              <%}%>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</form>
</body>
</html>
